<template>
<el-dialog title="批量更新跟进状态" :visible.sync="visible" append-to-body width="400px">
    <el-form :model="ruleForm" label-width="80px" label-position="left">
        <el-form-item label="跟进状态" prop="status">
            <picker-view type="visitStatus" v-model="ruleForm.status" placeholder="请选择跟进状态"></picker-view>
        </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
        <el-button @click="closeDialog">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
    </div>
</el-dialog>
</template>

<script>
import {
    batchUpdateStatusApi
} from "@/api/customer/member";
import pickerView from "@/components/picker/select.vue";

const ruleForm = {
    ids: [],
    status: "",
};

export default {
    name: "VisitStatusBatch",
    components: {
        pickerView,
    },
    data() {
        return {
            visible: false,
            ruleForm: Object.assign({}, ruleForm),
        };
    },
    methods: {
        showDialog(ids) {
            this.ruleForm = Object.assign({}, ruleForm);
            this.ruleForm.ids = ids;
            this.visible = true;
        },
        closeDialog() {
            this.visible = false;
        },
        // 添加联系方式
        submit() {
            if (!this.ruleForm.status) {
                this.$message({
                    type: "error",
                    message: "请选择跟进状态",
                });
                return;
            }

            // 系统联系方式唯一性检查
            batchUpdateStatusApi(this.ruleForm).then(res => {
                if (res.code == "200") {
                    this.$emit('reload');
                    this.closeDialog();
                } else {
                    this.$message({
                        type: "error",
                        message: res.msg,
                    });
                }
            });
        },
    },
};
</script>

<style lang="scss" scoped>
.w100 {
    width: 100%;
}
</style>
